Lossless image compression techniques are preferred in image pre-processing/editing, for archiving in original high quality, in medical imaging, cartoon images, area maps, etc. Existing lossless image compression techniques are not optimized for compressing few-colored images (e.g., 1024 or less colors). For example, the GIF (graphics interchange format) file format is limited to two-hundred and fifty-six colors, but the compression achieved is not optimal. Whereas, the PNG (portable network graphics) file format compresses few-colored images better than GIF, PNG works on principles best-suited for compressing images with thousands or millions of colors. Thus, existing lossless image compression techniques are not optimized for compressing few-colored images.